import request  from '@/utils/request';

import { OPS_URL } from '@/config/query';

export async function queryPage(params = { pageSize: 10, pageNum: 0 }) {
  return request(`${OPS_URL}/role/page`, params)
}

export async function queryInfoById(id) {
  return request(`${OPS_URL}/role/detail/${id}`)
}

export async function create(params) {
  return request(`${OPS_URL}/role/create`, params)
}

export async function update(params) {
  return request(`${OPS_URL}/role/modify`, params)
}

export async function remove(id) {
  return request(`${OPS_URL}/role/remove/${id}`)
}

export async function queryAuthById(id) {
  return request(`${OPS_URL}/role/permission_list/${id}`)
}

export async function queryMenuTree(id) {
  return request(`${OPS_URL}/role/menu_tree/${id}`);
}

export async function setAuthByIdChecked(id, resourceIdList) {
  return request(`${OPS_URL}/role/allot_permission`, {
    roleId: id,
    menuIdList: resourceIdList
  });
}
